package com.yanqu.road.logic.activity.foxcard.game.effect;

import com.yanqu.road.entity.activity.foxcard.FoxEffectCard;
import com.yanqu.road.entity.activity.foxcard.FoxHandCard;
import com.yanqu.road.entity.activity.foxcard.config.FoxCardEffectCardConfig;
import com.yanqu.road.logic.activity.foxcard.game.FoxCardGameLogic;
import com.yanqu.road.logic.activity.foxcard.game.eFoxCardTriggerType;

/**
 * 复制右边小丑牌的效果
 */
public class FoxCardEffect24 extends FoxCardEffectBase {
    @Override
    protected void effectHandle(FoxCardGameLogic gameLogic, FoxHandCard handCard) {
        if(triggerType == eFoxCardTriggerType.ROUND_START ||
                triggerType == eFoxCardTriggerType.SCORE ||
                triggerType == eFoxCardTriggerType.AFTER_SCORE ||
                triggerType == eFoxCardTriggerType.SHOPPING_END
        ) {
            //找到list右边的牌
            int idx = gameLogic.getGameData().getEffectCards().indexOf(effectCard);
            if (idx < 0 || idx >= gameLogic.getGameData().getEffectCards().size() - 1) {
                return;
            }
            FoxEffectCard rightCard = gameLogic.getGameData().getEffectCards().get(idx + 1);
            FoxCardEffectCardConfig effectCardConfig = gameLogic.getConfig().getEffectCardConfigMap().get(rightCard.getConfigId());
            if (effectCardConfig == null) {
                return;
            }
            if (effectCardConfig.getType() == 23 || effectCardConfig.getType() == 24) {//复制的牌也是复制不触发
                return;
            }
            FoxEffectCard clone = rightCard.clone();
            clone.setId(effectCard.getId());
            gameLogic.dealCardEffect(clone, triggerType, handCard);
        }
    }
}
